<?php
/**
 * Created by PhpStorm.
 * User: zd
 * Date: 2019/1/3
 * Time: 17:19
 */

namespace app\api\controller\v1;


use app\api\controller\BaseController;
use app\api\service\Token;
use app\api\service\Card;
use app\common\lib\Redis;
use app\lib\exception\UserException;


class Web extends BaseController
{
    /**
     * 获取官网信息
     * @return mixed
     * @throws UserException
     */
    public function getWebInfo(){
        $uid = Token::getCurrentUid();
        $manager_id =  Token::getCurrentTokenVar('manager_id');
        $thirdApp = new Card();
        $result =  $thirdApp->getWebInfo($manager_id);
        if (!$result ){
            throw new UserException([
                'code'=>201,
                'msg'=>"官网信息不存在",
                'error_code'=>60009
            ]);
        }
        return $result;
    }
    /**
     * 获取子元素信息
     * @param $sub_id
     * @return array|false|\PDOStatement|string|\think\Model
     * @throws UserException
     */
    public function getConsulting($sub_id,$type){
        $uid = Token::getCurrentTokenVar('manager_id');
        $thirdApp = new Card();
        $result =  $thirdApp->getSubWebInfo($uid,$sub_id,$type);
        if (!$result ){
            throw new UserException([
                'code'=>201,
                'msg'=>"官网信息不存在",
                'error_code'=>60009
            ]);
        }
        return $result;
    }
}